<?php
/**
 * 邮件模板
 * Enter description here ...
 * @author nijn
 *
 */
class EmailTemplate {

	/**
	 * 模板文件
	 * Enter description here ...
	 * @var unknown_type
	 */
	protected $_template = 'default';

	static public function getInstance($template = '') {
		$model = new self();
		if ($template) {
			$model->_template = $template;
		}
		return $model;
	}

	/**
	 * 返回模板内容
	 * Enter description here ...
	 * @param unknown_type $model
	 */
	public function getTemplateContent($model) {
		return $this->getTemplate($model);
	}

	/**
	 * 获取模板
	 * Enter description here ...
	 * @param unknown_type $model
	 */
	protected function getTemplate($model) {
		ob_start();
		include Yii::app()->basePath.'/config/emailTemplate/'.$this->_template.'.php';
		$content = ob_get_clean();

		$datas = include Yii::app()->basePath.'/config/emailTemplate/'.$this->_template.'_data.php';

		foreach ($datas as $key=>$one) {
			$content = str_replace($key, eval('return '.$one.';'), $content);
		}
		return $content;
	}
}

?>